home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE13 / CLINIC / MOVEU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-07-30  |  1.3 KB  |  62 lines

  1. unit MoveU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Buttons, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Label1: TLabel;
  12.     Button1: TButton;
  13.     ListBox1: TListBox;
  14.     GroupBox1: TGroupBox;
  15.     BitBtn1: TBitBtn;
  16.     SpeedButton1: TSpeedButton;
  17.     procedure GenericMouseMove(Sender: TObject; Shift: TShiftState; X,
  18.       Y: Integer);
  19.     procedure FormCreate(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TForm1.GenericMouseMove(Sender: TObject; Shift: TShiftState; X,
  34.   Y: Integer);
  35. type
  36.   TBoolStrings = array[Boolean] of String;
  37. const
  38.   Vert: TBoolStrings = ('Bottom', 'Top');
  39.   Horz: TBoolStrings = ('right', 'left');
  40. var
  41.   Pt: TPoint;
  42. begin
  43.   Pt := Point(X, Y);
  44.   Pt := Form1.ScreenToClient((Sender as TControl).ClientToScreen(Pt));
  45.   with Pt do
  46.     Caption := Format('%s %s (%d,%d)',
  47.       [Vert[Y < ClientHeight div 2],
  48.        Horz[X < ClientWidth div 2],
  49.        X, Y]);
  50. end;
  51.  
  52. procedure TForm1.FormCreate(Sender: TObject);
  53. var
  54.   Loop: Integer;
  55. begin
  56.   for Loop := 0 to ComponentCount - 1 do
  57.     if Components[Loop] is TControl then
  58.       TButton(Components[Loop]).OnMouseMove := GenericMouseMove
  59. end;
  60.  
  61. end.
  62.